<template>
    <div>
        <el-button @click="add()">保存</el-button>
    </div>


    <h1 style="text-align: center;font-weight: bold;">销售退款</h1>
    <table border="1" style="border-collapse: collapse; width: 100%; height: 40px;">
        <tr>
            <td>客户名称</td>
            <td><input v-model="form.clientName" type="text" style="height: 40px;width: 100%;text-align: center;"
                    :disabled="true" />
            </td>
        </tr>
        <tr>
            <td>计划退款金额</td>
            <td><input v-model="form.salesReturnAmout" type="text" style="height: 40px;width: 100%;text-align: center;"
                    :disabled="true" />
            </td>
        </tr>
        <tr>
            <td>本次退款金额</td>
            <td><input v-model="form.amountRefund" type="text" style="height: 40px;width: 100%;text-align: center;" />
            </td>
        </tr>
        <tr>
            <td>计划退款日期</td>
            <td><input v-model="form.planRefundDate" type="date" style="height: 40px;width: 100%;text-align: center;" />
            </td>
        </tr>
        <tr>
            <td>退款方式</td>
            <td>
                <el-select v-model="form.refundPaceWay" placeholder="请选择退款方式">
                    <el-option label="现金" :value="1">现金</el-option>
                    <el-option label="转账" :value="2">转账</el-option>
                    <el-option label="支票" :value="3">支票</el-option>
                    <el-option label="微信" :value="4">微信</el-option>
                </el-select>
            </td>
        </tr>
    </table>

</template>

<script setup lang='ts'>
import axios from 'axios'
import * as XLSX from 'xlsx';
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
import http from '../../../http.js'


const form = reactive({
    clientName: "",
    salesReturnAmout: "",
    "planRefundDate": "2024-12-26T06:02:06.726Z",
    "amountRefund": "",
    "refundPaceWay": "",
    "refundPlanCode": "",
    "salesReturnId": ""
})

//反填
const GetDirectList = () => {
    axios.get(http.zblnb + '/cw/api/SalesReturn/GetSalesDirectDebitList?SalesReturnId=' + route.query.salesReturnId)
        .then(res => {
            let d = res.data.data;
            form.clientName = d.clientName;
            form.salesReturnAmout = d.salesReturnAmout;
            console.log(res.data.data)
        })
}

//添加保存
const add = () => {
    const model = {
        refundPlanCode: form.refundPlanCode,
        amountRefund: form.amountRefund,
        planRefundDate: form.planRefundDate,
        refundPaceWay: form.refundPaceWay,
        salesReturnId: route.query.salesReturnId,
    }
    console.log(model)
    axios.post(http.zblnb + '/cw/api/SalesReturn/AddSalesDirectDebit', model)
        .then(res => {
            if (res.data.data > 0) {
                ElMessage.success('添加成功');
                router.push('/ListSalesShouldRefund');
            }
            else {
                ElMessage.error('添加失败');
            }
        })
}


onMounted(() => {
    GetDirectList();
})



</script>

<style></style>